﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using Telerik.Web.UI;
using System.Globalization;

namespace KPIS.GERP.GHRMS.APP.App_UI.Forms
{
    public partial class PR_BudgetManagementTestDtl : System.Web.UI.Page
    {
        private SsMng ssMng = new SsMng();
        int recordCount = 0;
        int mng_seq = 0;
        private BudgetManagementTestDtlBLL dtsBLL = new BudgetManagementTestDtlBLL();
        private PromoteEmployeeBLL prBLL = new PromoteEmployeeBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            FirstLoadDataGrid(int.Parse(Request.QueryString["mng_test_seq"].ToString()));
        }
        private void LoadDataGridSumPosType()
        {
            int mng_test_seq = int.Parse(Request.QueryString["mng_test_seq"].ToString());
            DataTable dt = dtsBLL.ListPromotionEmployees(mng_test_seq);

            //RadGrid gridPosType = (RadGrid)RadPanelBar1.FindItemByValue("AccountInformation").FindControl("gridPosType");

            RadGrid1.DataSource = dt;
            RadGrid1.DataBind();
        }
        private void FirstLoadDataGrid(int mng_seq)
        {
            IBudgetManagementTestDtlBLL obj = new BudgetManagementTestDtlBLL();

            DataSet ds = obj.ListManagementDtl(mng_seq);

            recordCount = ds.Tables[0].Rows.Count;
            RadGrid2.DataSource = ds.Tables[0];
            RadGrid2.DataBind();
            RadGrid2.MasterTableView.EditMode = GridEditMode.InPlace;
        }

        protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
                {
                    e.Item.Cells[5].Text = "<a href='Javascript: openProjectDetails(" + e.Item.Cells[2].Text 
                        + "," + e.Item.Cells[4].Text
                        + "," + Session["PrmSeq"].ToString()
                        + "," + Session["JobSiteSeq"].ToString()
                        + ");' onclick='Javascript:return openProjectDetails(" + e.Item.Cells[2].Text + "," + e.Item.Cells[4].Text + "," + Session["PrmSeq"].ToString() + "," + Session["JobSiteSeq"].ToString() + ");'>" + e.Item.Cells[5].Text + "</a>";
                    //e.Item.Cells[5].Text = "<asp:LinkButton ID='targetControl' runat='server' Text='<%# Eval('" + e.Item.Cells[5].Text + "')%>' OnClientClick='<%# Eval(" + e.Item.Cells[5].Text + ",Javascript:return openProjectDetails('1','1')) %>'></asp:LinkButton> ";

                }

            }

            catch (Exception ex)
            {

            }
            finally
            {
                if (e.Item.Cells.Count >= recordCount)
                {
                    e.Item.Cells[2].Visible = false;
                    e.Item.Cells[3].Visible = false;
                    e.Item.Cells[4].Visible = false;
                } 
            }
        }
        protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "Delete")
            {


                //int seq = Convert.ToInt32((e.Item as GridDataItem).OwnerTableView.DataKeyValues[e.Item.ItemIndex]["cr_seq"]);
                //// salaryCommandBLL.Delete(seq, ssMng.EmpSeq);
                //CrimesBLL obj = new CrimesBLL();
                //obj.Delete(seq, 1);

            }
            LoadDataGridSumPosType();
        }
        protected void cmdShowManage_Click1(object sender, EventArgs e)
        {
            prBLL.UpdateSelect(Int32.Parse(Request.QueryString["mng_test_seq"].ToString())
                            , ssMng.EmpSeqI);
            LoadDataGridSumPosType();
        }
      
   
    }
}
